class Person {
    constructor(name) {
        this.name = name;
        this.proxy = new Proxy(this, {
            get: function (target, property) {
                if (!target.hasOwnProperty(property) && !target[property]) {
                    target.speak(`What is '${property}'?`);
                    return function () { };
                }
                return target[property];
            }
        });
        return this.proxy;
    }

    speak(word) {
        console.log(`${this.name}: ${word}`);
    }
}

class USPlayer extends Person {
    attack() {
        this.speak("Attack!");
    }

    defense() {
        this.speak("Defense!");
    }
}

class ForeignPlayer extends Person {
    chineseAttack() {
        this.speak("进攻！");
    }

    chineseDefense() {
        this.speak("防守！");
    }
}

class Translator extends Person {
    constructor(person) {
        super("Translator to " + person.name);
        this.person = person;
    }

    attack() {
        this.speak("进攻！");
        this.person.chineseAttack();
    }

    defense() {
        this.speak("防守！");
        this.person.chineseDefense();
    }
}

var main = function () {
    var badier = new USPlayer("Badier");
    var maidi = new USPlayer("Maidi");
    var yaoming = new ForeignPlayer("Yaoming");
    var translator = new Translator(yaoming);

    badier.attack();
    maidi.attack();
    yaoming.attack();
    yaoming.defense();
    translator.attack();
    translator.defense();
};


// The output should be:
// "Badier: Attack!"
// "Maidi: Attack!"
// "Yaoming: What is 'attack'?"
// "Yaoming: Waht is 'defense'?"
// "Translator to Yaoming: 进攻！"
// "Yaoming: 进攻！"
// "Translator to Yaoming: 防守！"